package com.gxa.ehome.Command2;

import com.gxa.ehome.Command1.Light;
import com.gxa.ehome.Command1.Stereo;
//这是一个传统的遥控器
public class TraditionControl  implements Control{
    Light light;
    Stereo stereo;
//实现控制器传入灯和音响

    public TraditionControl(Light light, Stereo stereo) {
        this.light = light;
        this.stereo = stereo;
    }

    @Override
    public void onButton(int slot) {
        switch(slot){
            case 0:
                light.On();
                break;
            case 1:
                stereo.On();
                break;
            case 2:
                int vol=stereo.GetVol();//获得音量
                if(vol<11){//音量最高是11自动判断
                    stereo.SetVol(++vol);
                }
        }

    }

    @Override
    public void offButton(int slot) {
        switch (slot){
            case 0:
            light.Off();
            break;
            case 1:
                stereo.Off();
                break;
            case 2:
                int vol=stereo.GetVol();//获得音量
                if(vol>0){//大于0音量减小
                    stereo.SetVol(--vol);
                    break;
                }

        }

    }

}
